xentrace: fix lost records resume
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 12 Apr 2010 17:28:33 +0000 (18:28 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 12 Apr 2010 17:28:33 +0000 (18:28 +0100)
Reorder the SCHED_SWITCH trace before the runstate change trace to fix
a problem with the lost records "resume" code.

Namely: The "lost records" trace includes the currently running
process.  But during SCHED_SWITCH, it reads the wrong value, confusing
xenalyze.  Making sure there are no trace records between runstate
change trace and the actual context switch fixes it.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
xen/common/schedule.c

index fdb9e8d0d203f726637f3e1613e153a2daeb75b4..70289041d2a9e4c41ca3161081ae11dcc7e95676 100644 (file)
@@ -877,6 +877,11 @@ static void schedule(void)
              next_slice.time);
 
     ASSERT(prev->runstate.state == RUNSTATE_running);
+
+    TRACE_4D(TRC_SCHED_SWITCH,
+             prev->domain->domain_id, prev->vcpu_id,
+             next->domain->domain_id, next->vcpu_id);
+
     vcpu_runstate_change(
         prev,
         (test_bit(_VPF_blocked, &prev->pause_flags) ? RUNSTATE_blocked :
@@ -887,6 +892,11 @@ static void schedule(void)
     ASSERT(next->runstate.state != RUNSTATE_running);
     vcpu_runstate_change(next, RUNSTATE_running, now);
 
+    /*
+     * NB. Don't add any trace records from here until the actual context
+     * switch, else lost_records resume will not work properly.
+     */
+
     ASSERT(!next->is_running);
     next->is_running = 1;
 
@@ -900,10 +910,6 @@ static void schedule(void)
     update_vcpu_system_time(next);
     vcpu_periodic_timer_work(next);
 
-    TRACE_4D(TRC_SCHED_SWITCH,
-             prev->domain->domain_id, prev->vcpu_id,
-             next->domain->domain_id, next->vcpu_id);
-
     context_switch(prev, next);
 }